package com.mobdev.notepad.sync;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.mobdev.notepad.NotepadProvider;
import com.mobdev.notepad.PreferencesActivity;
import com.mobdev.notepad.R;
import com.mobdev.notepad.shared.AbstractSyncActivity;
import com.mobdev.notepad.shared.helipad.SyncThread;

public class SyncActivity extends AbstractSyncActivity
{
    /**
     * Initialization of the Activity after it is first created.  Must at least
     * call {@link android.app.Activity#setContentView setContentView()} to
     * describe what is to be displayed in the screen.
     */
    @Override
	protected void onCreate(Bundle savedInstanceState) {
        // Be sure to call the super class.
        super.onCreate(savedInstanceState);

		//init ui
        requestWindowFeature(Window.FEATURE_LEFT_ICON);


        // See assets/res/any/layout/dialog_activity.xml for this
        // view layout definition, which is being set here as
        // the content of our screen.
        setContentView(R.layout.sync_activity);

        textView = (TextView) findViewById(R.id.sync_activity_textview1);

        // Link up with the Conflict button panel buttons.
        buttonPanel = findViewById(R.id.sync_activity_button_panel);
        buttonPanel.setVisibility(View.GONE);

        button0 = (Button) findViewById(R.id.sync_activity_button0);
        button1 = (Button) findViewById(R.id.sync_activity_button1);
        button2 = (Button) findViewById(R.id.sync_activity_button2);
        getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
                android.R.drawable.ic_popup_sync);

        //start the thread
        // Launch activity to insert a new item
    	if(syncThread == null || !syncThread.isAlive())
    	{
			//initialize data
       	 	getIntent().setData( NotepadProvider.NOTEPAD_URI );

    		syncThread = new SyncThread(this);
    		syncThread.start();
    		//Toast.makeText(this, "Syncing..", 700);
    	}
    }


	@Override
	public void showPreferences() {
		startActivity(new Intent(this, PreferencesActivity.class));
	}




	@Override
	public String getLocalyticsAppKey() {

		return NotepadProvider.LOCALYTICS_APP_KEY;
	}

}
